package com.TestPage;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zjg.db.utills.JdbcTemplate;



public class TestPageDao {
    public void getData(TestPageBean<List<Map<String,Object>>> page) {
    	String sql="select * from ( select * from ( select basetable.* ,rownum r from ("+page.getTableName()+") basetable ) where r<=(?*?)) where r>(?-1)*?";
    			
    	List<Map<String,Object>> list=JdbcTemplate.query(sql, (rs)->{
    		List<Map<String,Object>> list0=new ArrayList<Map<String,Object>>();
    		
    		try {
				while(rs.next()) {
					
					Map<String,Object> map=new HashMap<String,Object> ();
					for(int i=1;i<=rs.getMetaData().getColumnCount();i++) {
						
						map.put(rs.getMetaData().getColumnName(i), rs.getObject(i));
					}
					list0.add(map);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
    		return list0;
    	}, new Object[] {page.getNowPage(),page.getSoloPageColunnum(),page.getNowPage(),page.getSoloPageColunnum()});//
    	page.setPageDataMap(list);
    	
    }
}
